package com.itransition.starnetwork;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 * Created by IntelliJ IDEA.
 * User: Игорь
 * Date: 16.10.11
 * Time: 19:49
 * To change this template use File | Settings | File Templates.
 */
public class Main {
    public static void main( String [] args ) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
            User user1 = new User();
            user1.setUsername("hector");
            user1.setPassword("lepota21");
            user1.setFirstName("Igor");
            user1.setLastName("Sukach");
            session.save(user1);
            transaction.commit();
        }   catch ( HibernateException exception ) {
            transaction.rollback();
            exception.printStackTrace();
        }   finally {
            session.close();
        }
    }
}
